app.controller('rentDetailsCtrl', function($element, $scope, $state, rest, user, uploadConf, tipService, $window, $rootScope,$filter) {
	$scope.contractDatas = angular.copy($scope.ngDialogData, {});
	var token = $window.localStorage.getItem("token");
	console.log($scope.contractDatas)
    $scope.hideBtn = function(){
    	$scope.closeThisDialog();
    }
    
    function GetDateRegion(beg,end){
    	var date1 = new Date(beg); //开始日期
		var date2 = new Date(end); //接受日期
		 
		var s1 = date1.getTime(),s2 = date2.getTime();
		var total = (s2 - s1)/1000;
		 
		var day = parseInt(total / (24*60*60));//计算整数天数
		var afterDay = total - day*24*60*60;//取得算出天数后剩余的秒数
		var hour = parseInt(afterDay/(60*60));//计算整数小时数
		var afterHour = total - day*24*60*60 - hour*60*60;//取得算出小时数后剩余的秒数
		var min = parseInt(afterHour/60);//计算整数分
		var afterMin = total - day*24*60*60 - hour*60*60 - min*60;//取得算出分后剩余的秒数
		//console.log([day,hour,min,afterMin].join(':'));
		return day;
    }
    
    $scope.fixationTime = GetDateRegion($scope.contractDatas.fixationStartTime,$scope.contractDatas.fixationEndTime);
    $scope.flexibleTime = GetDateRegion($scope.contractDatas.flexibleStartTime,$scope.contractDatas.flexibleEndTime);
    $scope.leaseTime = Math.round(GetDateRegion($scope.contractDatas.leaseStartTime,$scope.contractDatas.leaseEndTime)/30);
    
});
